import axios from 'axios'
const $http = axios.create({
  baseURL: 'http://localhost:3000',
  timeout: 10000,
  headers: {
    'Content-Type': 'application/json;charset=UTF-8'
  },
  withCredentials: true
})

$http.interceptors.request.use(
  (config: any) => {
    return config
  },
  (error) => {
    return Promise.reject(error)
  }
)
$http.interceptors.response.use(
  (response: any) => {
    if (response.status === 200) {
      return response.data
    }
    return Promise.reject(response)
  },
  (error: any) => {
    return Promise.reject(error)
  }
)

export default $http
